package com.zy.explore.design.patterns.factory;

import org.springframework.stereotype.Component;

/**
 * 工厂模式使用服务类
 *
 * @author ZY
 * @date 2021/11/03
 */
@Component
public class FactoryUseService {

    public void resolveFile(String fileType) {
        // 构造不同的工厂对象
        IFileResolveFactory fileResolveFactory;
        if ("A".equals(fileType)) {
            fileResolveFactory = new AFileResolver();
        } else if ("B".equals(fileType)) {
            fileResolveFactory = new BFileResolver();
        } else {
            fileResolveFactory = new DefaultFileResolver();
        }
        fileResolveFactory.resolve();
    }

}
